package util;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

/**
 * 工具类
 * 
 * @author Administrator
 *
 */
public class HibernateUtil {

	private static SessionFactory factory;
	static {
		// 静态块 初始化工厂
		factory = new Configuration().configure("hibernate.cfg.xml").buildSessionFactory();
	}

	// 返回session
	public static Session currentSession() {
		return factory.getCurrentSession();
	}
}
